<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');



class P_type extends CI_Controller {



	     public function __construct()

       {

            parent::__construct();

		$this->load->helper("html");

		$this->load->helper("url");

		$this->load->helper('form');

		$this->load->helper('date');

		$this->load->model("p_type_model");

		//$this->load->model("guest_comment_model");

		//$this->load->model("news_events_model");

		//$this->load->model("roomcottages_model");

		$this->load->helper(array('form', 'url'));

		$this->load->database();

		

	}

	

	//START ------------------dv---------------------

	function index()

	{

		$data['title']="Administrator Page";

		$data["list_p_types"] = $this->p_type_model->get_all_p_type();	

		$this->load->view('p_type_list_view',$data);

	}



	function view_p_type()

	{

		$code = $this->uri->segment(3);

		$data["info"] = $this->p_type_model->getp_type_info($code);	

		$this->load->view('p_type_vw_view',$data);

		

	}

	

	function add_p_type()

	{

		//$data["driver_dv_data"] = $this->dv_model->add_view_driver_dv();

		$this->load->view('p_type_add_view');

	}

	function p_add_p_type()

	{

		

		$this->load->database();			

		$p_type =$_POST['txtp_type'];

		$_sql="insert into p_type(p_type)";

		$_sql.="values('$p_type')";

		$query = $this->db->query($_sql); 

	/*	$dv_id=$this->db->insert_id();

	 

		$_sql="insert into dv_contract(dv_id,contract_amount)";

		$_sql.="values($dv_id,$contract_amt)";

		$query = $this->db->query($_sql); */

			

		$data["list_p_types"] = $this->p_type_model->get_all_p_type();	

		$this->load->view('p_type_list_view',$data);

							

	}



	function edit_p_type()

	{

 	    $code = $this->uri->segment(3);

		$data["info"] = $this->p_type_model->getp_type_info($code);	

		$this->load->view('p_type_edit_view',$data);

	}

	

	function p_edit_p_type()

	{

		$this->load->database();

		    $id= $_POST['hid_id'];

			$p_type = $_POST['txtp_type'];

			$query = $this->db->query("UPDATE p_type SET 

												  		  

														  p_type='$p_type' where id=$id");

														  

		$data["list_p_types"] = $this->p_type_model->get_all_p_type();	

		$this->load->view('p_type_list_view',$data);		

	}

	

	

	function delete_p_type()

	{

		$this->load->database();		

		$code = $this->uri->segment(3);

		$query = $this->db->query("delete from profile where profile_id='$code'");

		

		$data["list_p_types"] = $this->p_type_model->get_all_p_type();	

		$this->load->view('p_type_list_view',$data);

	}

	//END ------------------dv---------------------

	

	

	function logout()

	{

		

		//$this->load->library('session');

		//$this->session->sess_destroy();

		session_start();

		session_destroy();

		//echo $_SESSION['Administrator_log'];

		//unset($_SESSION['Administrator_log']);

		

			//$data["newsresult"] = $this->dv_model->dv_all_driver_dv();

			$this->load->view('admin_view');

	 

	}

 

}

?>